function twoSum(numbers: number[], target: number): number[] {
    let low = 0;
    let high = numbers.length - 1;
    // 双指针入门
    while (low < high) {
        const sum = numbers[low] + numbers[high];

        if (sum === target) {
            return [low + 1, high + 1];
        } else if (sum < target) {
            // 小了
            low++;
        } else {
            // 打了
            high--;
        }
    }

    return [-1, -1]
};

function twoSum(numbers: number[], target: number): number[] {
    for (let i = 0; i < numbers.length; i++) {
        const diff = target - numbers[i];
        let low = i + 1;
        let high = numbers.length - 1;
        while (low <= high) {
            let mid = Math.floor((high - low) / 2 + low);
            if (diff === numbers[mid]) {
                return [++i, ++mid];
            } else if (diff < numbers[mid]) {
                // 大了
                high--;
            } else {
                low++;
            }
        }
    }
    return [-1, -1]
}